#学习网址：http://vip3.byhy.net/py/lang/extra/file_dir/

# os.makedirs()

#os.remove()
# shutil.rmtree()


# shutil.copyfile()
#shutil.copytree()

#os.rename()

#os.path模块可以对跨平台的路径进行操作
#os.path.isfile()
#os.path.exists()
#os.path.isdir()
#os.path.join()
#os.path.basename()
#os.path.dirname()
#os.path.getmtime()
#os.path.getsize()

#os.getcwd()
#os.chdir()

#os.walk()
#os.listdir()

import os
z = os.walk('/Users/show/Downloads/编程/python学习')
for i in z:
    print(i)

import glob
exe = glob.glob('/Users/show/Downloads/编程/python学习/*.txt')
print(exe)


import shutil
path1 = '/Users/show/Downloads/编程/python学习/source'


target_path = '/Users/show/Downloads/编程/python学习/backup/new'
target_file = 'source'

# os.makedirs(target_path)
# shutil.copytree(path1,os.path.join(target_path,target_file))

file_1 = os.listdir(path1)
size = 0
for i in file_1:
    r_path = os.path.join(path1,i)
    if os.path.isfile(r_path):
        file_size = os.path.getsize(r_path)
        size+=file_size

print(f'文件所有的大小为{size}')

# bmp_files = glob.glob(os.path.join(path1,'*bmp'))
# for i in bmp_files:
#     os.remove(i)


a = [i for i in os.listdir('/Users/show/Downloads/编程/python学习') if os.path.isfile(i)]
print(a)